"use strict";
cc._RF.push(module, '18015fS0PdCFKyZ9tnlUo9k', 'ReceiveAward');
// scripts/ReceiveAward.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GlobalUserData"),
    s = t("HallConstant"),
    l = t("BroadCastMessage"),
    c = t("ChannelTool"),
    d = t("NativeManager"),
    h = t("Util"),
    p = t("BonusUtil"),
    u = t("Award"),
    f = cc._decorator,
    m = f.ccclass,
    _ = f.property,
    y = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e._awards = [], e.awardScripts = [], e.singleNode = null, e.multiNode = null, e.sheer = null, e.multiSpr = null, e.titleSpr = null, e.titleFrame = null, e.three = null, e.toggie = null, e.tagNode = null, e.content = null, e.awardPrefab = null, e.closeNode = null, e.btnClose = null, e.btnShowAd = null, e.btnShowVideo = null, e.panel = null, e.videoIcon2 = null, e.TTVideoIcon2 = null, e.videoIcon = null, e.TTVideoIcon = null, e.coinPrefab = null, e.btnCancel = null, e.btnGet = null, e._multiple = 6, e._isVideo = !0, e.mistakeBannerTimer = null, e.canShowMistakeBanner = !0, e.isBtnClickOnce = !1, e;
  }

  return n(e, t), e.prototype.onLoad = function () {
    this.panel.setContentSize(cc.winSize);
  }, e.prototype.start = function () {
    var t = this;
    this.btnShowAd.active = !1, this.closeNode.active = !0, this.btnClose.active = !1, this.btnShowVideo.active = !1, this.btnCancel.active = !1, c.ChannelTool.curentChannel == c.ChannelTool.ChannelEnum.BYTE ? (this.videoIcon.active = this.videoIcon2.active = !1, this.TTVideoIcon.active = this.TTVideoIcon2.active = !0, h.Util.showBanner(), this.btnShowVideo.active = !0, this.btnClose.active = !1, setTimeout(function () {
      t.closeNode.active = !0;
    }, 0)) : h.Util.hideBanner(), h.Util.is_qg() && Math.random() <= r["default"].mistakeNativeBanneProbability && r["default"].bAuditMode, h.Util.hideSingleCustomAd(), h.Util.show_VerticalCustomAd(!1), h.Util.show_VerticalCustomAd(!0);
    var e = r["default"].nTotalGame % 6;
    h.Util.hideNativeBanner(), h.Util.hideHallBanner(), h.Util.showNativeBanner(1, this.btnShowAd, function () {
      h.Util.is_qg() && !r["default"].bAuditMode && r["default"].nativeMistakeBannerList[e] && (setTimeout(function () {
        t.closeNode.active = !0;
      }, 2e3), t.btnClose.active = !1);
    }), !r["default"].bAuditMode && this.canShowMistakeBanner && r["default"].isShowMistakeBanner ? h.Util.is_wx() && (h.Util.hideBanner(), this.mistakeBannerTimer = setTimeout(function () {
      h.Util.showMistakeBanner(function () {
        t.mistakeBannerTimer = setTimeout(function () {
          h.Util.hideMistakeBanner(), h.Util.showBanner();
        }, 2e3);
      }, function () {
        h.Util.showBanner();
      });
    }, 1e3)) : h.Util.is_wx() && h.Util.showBanner();
  }, e.prototype.onEnable = function () {
    r["default"].popup = this.node, h.Util.is_233() && d["default"].instance.showFullVideoAd();
  }, e.prototype.init = function (t, e, o, i, n) {
    void 0 === o && (o = !1), void 0 === n && (n = !0), this.canShowMistakeBanner = n, this._awards = t, this._callback = e, this._videoTab = i, this.addAward(), h.Util.videoExposure(this._videoTab), this._sheer = o, o ? (this.expression(!0), this.toggie.active = !1, this.singleNode.active = !1, this.multiNode.active = !1, this.sheer.active = !0, this.setValue(6)) : r["default"].bAuditMode && (h.Util.is_VIVO() || h.Util.is_tt) ? (this.expression(!1), this.toggie.getComponent(cc.Toggle).isChecked = !1) : this.expression(!0);
  }, e.prototype.addAward = function () {
    for (var t = 0; t < this._awards.length; t++) {
      var e = this._awards[t],
          o = cc.instantiate(this.awardPrefab);
      o.parent = this.content;
      var i = o.getComponent(u["default"]);
      i.Tag = e.tag, i.Icon = e.icon, i.Value = e.value, this.awardScripts.push(i);
    }
  }, e.prototype.setValue = function (t) {
    for (var e = 0; e < this._awards.length; e++) {
      var o = this._awards[e];
      this.awardScripts[e].Value = o.value * t;
    }
  }, e.prototype.initTag = function () {
    this.tagNode.setPosition(0, 0), this.tagNode.setScale(3, 3), this.tagNode.opacity = 0;
  }, e.prototype.Toggle = function (t) {
    this.expression(t.isChecked);
  }, e.prototype.expression = function (t) {
    this.tagNode.stopAllActions(), this.multiNode.active = t, this._isVideo = t, this.singleNode.active = !this.multiNode.active, t ? (this.setValue(this._multiple), this.initTag(), cc.tween(this.tagNode).to(1, {
      position: cc.v3(205, 30),
      opacity: 255,
      scale: 1
    }, {
      easing: "elasticOut"
    }).start()) : (this.setValue(1), cc.tween(this.tagNode).to(.5, {
      position: cc.v3(205, 30),
      opacity: 0,
      scale: 3
    }).start());
  }, e.prototype.receive = function () {
    l["default"].getInstance().SendMessage(s.Broadcast_Func.Audio, s.Audio_ID.btn_click), this._isVideo ? (r["default"].videoTab = this._videoTab, h.Util.showRewardVideo(this.getAward.bind(this))) : this.getAward();
  }, e.prototype.getAward = function () {
    var t = this;
    l["default"].getInstance().SendMessage(s.Broadcast_Func.Audio, s.Audio_ID.get_gold);

    for (var e = 0; e < this.awardScripts.length; e++) {
      var o = this.awardScripts[e];
      p["default"].receiveAward(o, this.coinPrefab);
    }

    this.node.getChildByName("btn").getComponent(cc.Button).interactable = !1, this._callback(), this.scheduleOnce(function () {
      t.closeUI();
    }, 1);
  }, e.prototype.onDestroy = function () {
    r["default"].popup = null;
  }, e.prototype.close = function () {
    this.isBtnClickOnce || r["default"].bAuditMode || !this.canShowMistakeBanner || !r["default"].isShowMistakeBanner ? (this.isBtnClickOnce = !1, h.Util.hideNativeBanner(), this.closeUI()) : this.isBtnClickOnce = !0;
  }, e.prototype.onClickNativeBanner = function () {
    h.Util.clickNativeBanner(1);
  }, e.prototype.closeUI = function () {
    clearTimeout(this.mistakeBannerTimer), h.Util.hideMistakeBanner(), h.Util.hideBanner(), h.Util.showHallBanner(), h.Util.showSingleCustomAd(), h.Util.hide_VerticalCustomAd(!1), h.Util.hide_VerticalCustomAd(!0), l["default"].getInstance().SendMessage(s.Broadcast_Func.Audio, s.Audio_ID.btn_click), this.node.destroy(), h.Util.hideNativeBanner();
  }, a([_(cc.Node)], e.prototype, "singleNode", void 0), a([_(cc.Node)], e.prototype, "multiNode", void 0), a([_(cc.Node)], e.prototype, "sheer", void 0), a([_(cc.Sprite)], e.prototype, "multiSpr", void 0), a([_(cc.Sprite)], e.prototype, "titleSpr", void 0), a([_(cc.SpriteFrame)], e.prototype, "titleFrame", void 0), a([_(cc.SpriteFrame)], e.prototype, "three", void 0), a([_(cc.Node)], e.prototype, "toggie", void 0), a([_(cc.Node)], e.prototype, "tagNode", void 0), a([_(cc.Node)], e.prototype, "content", void 0), a([_(cc.Prefab)], e.prototype, "awardPrefab", void 0), a([_(cc.Node)], e.prototype, "closeNode", void 0), a([_(cc.Node)], e.prototype, "btnClose", void 0), a([_(cc.Node)], e.prototype, "btnShowAd", void 0), a([_(cc.Node)], e.prototype, "btnShowVideo", void 0), a([_(cc.Node)], e.prototype, "panel", void 0), a([_(cc.Node)], e.prototype, "videoIcon2", void 0), a([_(cc.Node)], e.prototype, "TTVideoIcon2", void 0), a([_(cc.Node)], e.prototype, "videoIcon", void 0), a([_(cc.Node)], e.prototype, "TTVideoIcon", void 0), a([_(cc.Prefab)], e.prototype, "coinPrefab", void 0), a([_(cc.Node)], e.prototype, "btnCancel", void 0), a([_(cc.Node)], e.prototype, "btnGet", void 0), a([m], e);
}(cc.Component);

o["default"] = y;

cc._RF.pop();